#include"log.hpp"
#include"task.hpp"
#include"pthreadPool.hpp"
#include<ctime>
#include<signal.h>

char Get_op(int a)
{
    switch(a)
    {
        case 0:
            return '+';
        case 1:
            return '-';
        case 2:
            return '*';
        case 3:
            return '/';
        case 4:
            return '%';
        default:
            return '+';
    }
}

int main()
{
    //忽略浮点数异常信号
    signal(SIGFPE,SIG_IGN);
    signal(8,SIG_IGN);

    srand(time(nullptr));

    std::cout<<"code=0答案可信，否则不可信"<<std::endl;

    auto pool=pthreadPool<Task>::getInstace();
    pool->start();

    while(true) 
    {
        //创建任务
        int r1=rand()%100;
        int r2=rand()%100;
        int op=rand()%5;
        Task t(r1,r2,Get_op(op));

        //交给多线程处理任务
        pool->push(t);
        usleep(100000);
    }   

    return 0;
}